{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
</style>
<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>签到日志列表</legend>
    </fieldset>
    <div class="layui-tab">
        <ul class="layui-tab-title">
            <li class="{if $flag1==1}layui-this{/if}"><a href="{:url('dayList')}">考勤日报</a></li>
            <li class="{if $flag2==2}layui-this{/if}">考勤月报</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                <form class="layui-form" action="" style="float: left">
                    <div class="layui-form-item" >
                        <div class="layui-inline" >
                            <div class="layui-input-inline" style="width: 200px;">
                                <input type="text" class="layui-input" id="time" placeholder="点击选择年月(默认上月)">
                            </div>
                        </div>
                        <div class="layui-inline" >
                            <div class="layui-input-inline" style="width: 200px;">
                                <input type="text" id="keyword" name="keyword" autocomplete="off" placeholder="请输入教师姓名/教师编号" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline" >
                            <div class="layui-btn-group layui-inline">
                                <a  href="{:url('monthList')}" class="layui-btn layui-btn-primary">重置</a>
                                <button id="search" class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="formDemo" style="background-color: #009688;">
                                    <i class="layui-icon">&#xe615;</i>查找
                                </button>
                            </div>
                        </div>
                    </div>
                </form>

                <button id="last_month_the_report" class="layui-btn layui-btn-normal" type="button" style="background-color: #009688;float: right">
                    一键生成上月报表
                </button>

            </div>
        </div>
    </div>

    <table class="layui-table" id="list2" lay-filter="list2"></table>
</div>

{include file="common/foot"/}

<script>
    layui.use(['table','element','laydate'], function() {
        var table = layui.table, $ = layui.jquery, laydate = layui.laydate;

        var tableIn = table.render({
            id: 'user2',
            elem: '#list2',
            url: "{:url('monthList')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {field: 'teacher_no',title: '教师工号', width: 130},
                {field: 'true_name', title: '教师姓名', width: 120},
                {field: 'title', title: '所在部门', width: 150},
                {field: 'rule_name', title: '考勤规则', width: 150},
                {field: 'normal_num', title: '应出勤（天）', width: 120},
                {field: 'normal_num',title: '实际出勤（天）', width: 150},
                {field: 'late_num',title: '迟到（次）', width: 120},
                {field: 'leave_num',title: '请假（天）', width: 120},
                {field: 'absent_num',title: '旷工（天）', width: 120},
                {field: 'business_trip_num',title: '出差（天）', width: 120},
                {field: 'content',title: '备注', width: 200},
            ]],
            limit: 10 //每页默认显示的数量
        });

        //年月选择器
        laydate.render({
            elem: '#time'
            ,type: 'month'
        });

        $('#search').on('click', function () {
            var keyword = $('#keyword').val();
            var time = $('#time').val();
            if (($.trim(keyword) === '') && ($.trim(time) === '')) {
                layer.msg('{:lang("pleaseEnter")}查找信息！', {icon: 0});
                return;
            }

            //表格重载
            tableIn.reload({
                //传递额外参数
                where: {keyword: keyword,time:time}
            });
        });

        $('#last_month_the_report').on('click', function () {
            layer.msg('生成中',{icon:16,shade:0.01});
            $.post('{:url("last_month_report")}','',function (res) {
                if(res.code){
                    layer.closeAll();
                    //表格重载
                    tableIn.reload({
                    });
                }else{
                    layer.msg(res.msg, {icon: 2});
                }
            });
        });

    });


</script>
</body>
</html>